// Tags: SegmentTree, ScanLine
#include <algorithm>
#include <cstdio>

typedef long long ll;
const int N = 1e6 + 5;
int n, cnt;

struct Event {
  int x, y1, y2, typ;
  Event() {}
  Event(int x, int y1, int y2, int typ) : x(x), y1(y1), y2(y2), typ(typ) {}
  inline bool operator<(const Event &rhs) const {
    return x == rhs.x ? typ > rhs.typ : x < rhs.x;
  }
} eve[N];

struct Node {
  int val, tag;
} tr[N << 2];

inline void pushup(int x, int l, int r) {
  if (tr[x].tag) tr[x].val = r - l + 1;
  else
    tr[x].val = tr[x << 1].val + tr[x << 1 | 1].val;
}

void modify(int x, int l, int r, int L, int R, int v) {
  if (L <= l && r <= R) return tr[x].tag += v, pushup(x, l, r);
  int mid = (l + r) >> 1;
  if (L <= mid) modify(x << 1, l, mid, L, R, v);
  if (mid < R) modify(x << 1 | 1, mid + 1, r, L, R, v);
  pushup(x, l, r);
}

int query(int x, int l, int r, int L, int R) {
  if (L <= l && r <= R) return tr[x].val;
  int mid = (l + r) >> 1, res = 0;
  if (L <= mid) res += query(x << 1, l, mid, L, R);
  if (mid < R) res += query(x << 1 | 1, mid + 1, r, L, R);
  return res;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("P3875 [TJOI2010]被污染的河流.in", "r", stdin);
  freopen("P3875 [TJOI2010]被污染的河流.out", "w", stdout);
#endif
#endif

  scanf("%d", &n);
  for (int i = 1, x1, y1, x2, y2; i <= n; ++i) {
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    if (x1 == x2) {
      if (y1 > y2) std::swap(y1, y2);
      eve[++cnt] = Event(x1 - 1, y1, y2, 1);
      eve[++cnt] = Event(x1 + 1, y1, y2, -1);
    } else {
      if (x1 > x2) std::swap(x1, x2);
      eve[++cnt] = Event(x1, y1 - 1, y1 + 1, 1);
      eve[++cnt] = Event(x2, y1 - 1, y1 + 1, -1);
    }
  }
  std::sort(eve + 1, eve + cnt + 1);
  ll ans = 0;
  for (int i = 1; i <= cnt; ++i) {
    ans += 1ll * tr[1].val * (eve[i].x - eve[i - 1].x);
    modify(1, 0, N, eve[i].y1, eve[i].y2 - 1, eve[i].typ);
  }
  printf("%lld", ans);
  return 0;
}